/**
 * 
 */
// window.onload = startForm;
// function startForm() {
// //document.forms[0].onsubmit = submitLoginForm;
// }
function submitLoginForm() {
	if (checkLoginForm()) {
		loadXMLDoc();
	}
}

function checkLoginForm() {
	if (document.forms[0].username.value.length == 0) {
		document.getElementById("Result").innerHTML = "Enter your user name.";
		document.getElementById("Result").style.color = "red";
		return false;
	} else {
		var express = /^\w+(\s*\w*)$/;
		regx = RegExp(express);
		if (regx.test(document.forms[0].username.value) == false
				|| document.forms[0].username.value.length < 6)
		// if (regx.test(document.forms[0].username.value) == false)
		{
			document.getElementById("Result").innerHTML = "The user name you entered should be at least 6 characters long.";
			document.getElementById("Result").style.color = "red";			
			return false;
		}
	}

	if (document.forms[0].password.value.length < 6) {
		if (document.forms[0].password.value.length == 0) {
			document.getElementById("Result").innerHTML = "Enter your password.";
			document.getElementById("Result").style.color = "red";
		} else {
			document.getElementById("Result").innerHTML = "The password you entered should be at least 6 characters long.";
			document.getElementById("Result").style.color = "red";				
		}

		return false;
	}

	return true;
}
